From edadcf67980764c104c25c7c1a0ba91257b89698 Mon Sep 17 00:00:00 2001
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Date: Thu, 8 Dec 2016 23:33:30 +0100
Subject: [PATCH 1/2] Detect bfd.h to enable/disable sepdebugcrcfix building

tools/sepdebugcrcfix includes <bfd.h>, but this header from binutils
is not checked in the configure script. Due to this, sepdebugcrcfix is
attempted to be built even when <bfd.h> is not available. This commit
addresses that by adding the appropriate configure check.

This fixes the following build error:

tools/sepdebugcrcfix.c:31:17: fatal error: bfd.h: No such file or directory
compilation terminated.
make[3]: *** [tools/sepdebugcrcfix.o] Error 1

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
 Makefile.am  | 2 ++
 configure.ac | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index 863138c..d8a68f0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -168,9 +168,11 @@ elfdeps_SOURCES =	tools/elfdeps.c
 elfdeps_LDADD =		rpmio/librpmio.la
 elfdeps_LDADD +=	@WITH_LIBELF_LIB@ @WITH_POPT_LIB@
 
+if HAS_BFD_H
 rpmlibexec_PROGRAMS +=	sepdebugcrcfix
 sepdebugcrcfix_SOURCES = tools/sepdebugcrcfix.c
 sepdebugcrcfix_LDADD =	@WITH_LIBELF_LIB@
+endif # HAS_BFD_H
 endif
 endif
 
diff --git a/configure.ac b/configure.ac
index c5ae701..b99ecb8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -242,6 +242,9 @@ AC_CHECK_HEADERS([dwarf.h], [
 ])
 AM_CONDITIONAL(LIBDWARF,[test "$WITH_LIBDWARF" = yes])
 
+AC_CHECK_HEADERS([bfd.h])
+AM_CONDITIONAL(HAS_BFD_H, [test "${ac_cv_header_bfd_h}" = "yes"])
+
 #=================
 # Check for beecrypt library if requested.
 AC_ARG_WITH(beecrypt, [  --with-beecrypt         build with beecrypt support ],,[with_beecrypt=no])
-- 
2.7.4

